<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core" lang="pt-br">

<f:view>
	<ui:composition template="/template/templatePadrao.xhtml">
		<ui:define name="body">
		
			<h:form id="form_ps">	
				<p:growl id="growl" /> 
				<h:outputText value="Plano de Saúde" styleClass="breadcrumb"/>
				
				<h:panelGroup id="panel_ps">
					<p:panel header="Cadastro">
						<h:panelGrid columns="2">
							<h:outputText value="Nome do Plano de Saúde" />
							<h:inputText value="#{planoSaudeManager.planoSaude.nomePlanoSaude}" required="true" label="Nome do Plano de Saúde"/>
						</h:panelGrid>
						<p:commandButton action="#{planoSaudeManager.save}" value="Salvar" rendered="#{planoSaudeManager.planoSaude.id == null}" update="form_ps,growl"/>
						<p:commandButton action="#{planoSaudeManager.update}" value="Salvar" rendered="#{planoSaudeManager.planoSaude.id != null}" update="form_ps,growl"/>
						
					</p:panel>
				</h:panelGroup>

				<h:panelGroup id="panel_table">
					<p:dataTable value="#{planoSaudeManager.listPlanoSaude}" var="ps" rows="5" paginator="true"
					emptyMessage="Não existem resultados."
					>
						<p:column headerText="Nome do Plano de Saúde">
							<h:outputText value="#{ps.nomePlanoSaude}" />
						</p:column>
						<p:column headerText="Ação">
							<p:commandButton action="#{planoSaudeManager.prepareUpdate}" value="Atualizar" process="@this" update=":form_ps:panel_ps,:form_ps:growl">
								<f:setPropertyActionListener target="#{planoSaudeManager.planoSaude}" value="#{ps}" />
							</p:commandButton>
							<p:commandButton action="#{planoSaudeManager.delete}" value="Excluir" process="@this" update=":form_ps:panel_table,:form_ps:growl">
								<f:setPropertyActionListener target="#{planoSaudeManager.planoSaude}" value="#{ps}" />
							</p:commandButton>
						</p:column>
					</p:dataTable>
				</h:panelGroup>
			
			</h:form>
		
		</ui:define>
	</ui:composition>
</f:view>
</html>